﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodWorx.Core.DomainModel;

namespace MethodWorx.CMS.Content
{
    public class PageTemplateRepository : QueryableRepository<PageTemplate>, IPageTemplateRepository
    {
        public PageTemplateRepository()
            : this(new PageTemplate[] { }.AsQueryable())
        {
        }

        public PageTemplateRepository(IQueryable<PageTemplate> source) 
            : base(source)
        {
            
        }


        public override void Delete(PageTemplate entity)
        {
            throw new NotImplementedException();
        }

        public override void Insert(PageTemplate entity)
        {
            throw new NotImplementedException();
        }

        public override void Update(PageTemplate entity)
        {
            throw new NotImplementedException();
        }

        public PageTemplate FindByName(string name)
        {
            return this.source.Where(pt => pt.Name == name).FirstOrDefault();
        }

        public override PageTemplate OnCreateEntityInstance()
        {
            return new PageTemplate();
        }

        public PageTemplate FindRoot()
        {
            return this.source.FirstOrDefault(pt => pt.AllowedAtRoot == true);
        }

        public IEnumerable<PageTemplate> FindAbstract()
        {
            return this.source.Where(pt => pt.Abstract == true);
        }


        public PageTemplate FindAbstractPageTemplateByName(string name)
        {
            return this.source.FirstOrDefault(pt => pt.Abstract == true && pt.Name == name);
        }

        public void Insert(object entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(object entity)
        {
            throw new NotImplementedException();
        }

        public void Update(object entity)
        {
            throw new NotImplementedException();
        }

        #region IPageTemplateRepository Members


        public IEnumerable<PageTemplate> FindContainingContentTemplate(ContentTemplate contentTemplate)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<PageTemplate> FindContainingPageTemplate(PageTemplate contentTemplate)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
